package com.sky.config;

import com.sky.properties.OssProperties;
import com.sky.utils.OssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类，用于创建OssUtil对象
 */

@Configuration
@Slf4j
public class OssConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public OssUtil ossUtil(OssProperties ossProperties){
        log.info("开始创建oss文件上传对象，{}",ossProperties);
        return new OssUtil(ossProperties.getDomain(),
                ossProperties.getAccessKeyId(),
                ossProperties.getSecretKeySecret(),
                ossProperties.getBucketName());
    }

}
